package cn.udinghuo.model.archives.system;

import com.fasterxml.jackson.annotation.JsonSetter;

import org.springframework.util.Assert;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import cn.udinghuo.core.domain.entity.BaseEntity;	
import cn.udinghuo.core.domain.entity.itf.Treeable;	
import java.util.Optional;
import cn.udinghuo.core.domain.entity.Comment;
import cn.udinghuo.core.domain.entity.ita.CacheKey;
import cn.udinghuo.core.domain.entity.ita.NoCache;

/**
 * @author yueyibo
 *	基础商品分类
 */
@Entity
@NoCache
@Table(name="basicproductclass")
public class BasicProductClass extends BaseEntity<Long> implements Treeable<Long> {

	private static final long serialVersionUID = -553648129L;
	/**
	* 分类名称name
	*/
	@Comment(value="分类名称")
	@Column(name="cName")
	private String name;
	/**
	* 分类编码code
	*/
	@Comment(value="分类编码")
	@Column(name="cCode")
	private String code;
	/**
	* 父IDparentId
	*/
	@Comment(value="父ID")
	@Column(name="iParentId")
	private Long parentId;
	/**
	* 级别：是树形结构的第几级level
	*/
	@Comment(value="级别：是树形结构的第几级")
	@Column(name="iDepth")
	private Integer level;
	/**
	* 路径path
	*/
	@Comment(value="路径")
	@Column(name="cPath")
	private String path;
	/**
	* 排序号sort
	*/
	@Comment(value="排序号")
	@Column(name="iOrder")
	private Integer sort;
	/**
	* 是否末级isLastNode
	*/
	@Comment(value="是否末级")
	@Column(name="bFinalLevel")
	private Boolean isLastNode;
	/**
	* 状态status
	*/
	@Comment(value="状态")
	@Column(name="iStatus")
	private Boolean status;
	/**
	* 数据来源IDoutSysKey
	*/
	@Comment(value="数据来源ID")
	@Column(name="cOutSysKey")
	private String outSysKey;
    @Override
    public void setParentId(Long parent) {
        this.isLastNode = (null == parent) ? true : false;
        this.parentId = parent;
    }

    @Override
    public Optional<Long> getParentId() {
        if(null == this.parentId){
            return Optional.empty();
        }
        return Optional.of(this.parentId);
    }
     @Override
    public Integer getLevel() {
        if(null == this.level){
            this.level = 1;
        }
        return this.level;
    }

    @Override
    public void setLevel(Integer level) {
        if(null == level){
            level = 1;
        }
        this.level = level;
    }
     @Override
    public String getPath() {
        return this.path;
    }

    @Override
    public void setPath(String path) {
        this.path = path;
    }
    @Override
    public Integer getSort() {
        return this.sort;
    }

    @Override
    public void setSort(Integer sort) {
        this.sort = sort;
    }
     public Boolean isLastNode() {
        if(null == this.isLastNode){
            this.isLastNode = true;
        }
        return this.isLastNode;
    }

    public void setIsLastNode(boolean isLastNode) {
        this.isLastNode = isLastNode;
    }
	public String getName() {
		return this.name;
	}
	
	public void setName(String value) {
		this.name = value;
	}
	
	@CacheKey
	public String getCode() {
		return this.code;
	}
	
	public void setCode(String value) {
		this.code = value;
	}
	
	
	
	
	
	
	public Boolean getStatus() {
		if(this.status == null){
			return true;
        }
		return this.status;
	}
	
	public void setStatus(Boolean value) {
		this.status = value;
	}
	
	public String getOutSysKey() {
		return this.outSysKey;
	}
	
	public void setOutSysKey(String value) {
		this.outSysKey = value;
	}
	
}
